.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document.  The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
.\" Copyright (c) 2000, Sun Microsystems, Inc.  All Rights Reserved
.\"
.TH WRITE 1 "Nov 3, 2000"
.SH NAME
write \- write to another user
.SH SYNOPSIS
.LP
.nf
\fBwrite\fR \fIuser\fR [\fIterminal\fR]
.fi

.SH DESCRIPTION
.sp
.LP
The \fBwrite\fR utility reads lines from the user's standard input and writes
them to the terminal of another user. When first invoked, it writes the
message:
.sp
.in +2
.nf
Message from \fIsender-login-id\fR (\fIsending-terminal\fR) [date]...
.fi
.in -2
.sp

.sp
.LP
to \fIuser\fR. When it has successfully completed the connection, the sender's
terminal will be alerted twice to indicate that what the sender is typing is
being written to the recipient's terminal.
.sp
.LP
If the recipient wants to reply, this can be accomplished by typing
.sp
.in +2
.nf
write \fIsender-login-id\fR [\fIsending-terminal\fR]
.fi
.in -2
.sp

.sp
.LP
upon receipt of the initial message. Whenever a line of input as delimited by a
\fBNL\fR, \fBEOF\fR, or \fBEOL\fR special character is accumulated while in
canonical input mode, the accumulated data will be written on the other user's
terminal. Characters are processed as follows:
.RS +4
.TP
.ie t \(bu
.el o
Typing the alert character will write the alert character to the recipient's
terminal.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Typing the erase and kill characters will affect the sender's terminal in the
manner described by the \fBtermios\fR(3C) interface.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Typing the interrupt or end-of-file characters will cause \fBwrite\fR to write
an appropriate message (EOT\en in the C locale) to the recipient's terminal and
exit.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Typing characters from \fBLC_CTYPE\fR classifications \fBprint\fR or
\fBspace\fR will cause those characters to be sent to the recipient's terminal.
.RE
.RS +4
.TP
.ie t \(bu
.el o
When and only when the \fBstty\fR \fBiexten\fR local mode is enabled,
additional special control characters and multi-byte or single-byte characters
are processed as printable characters if their wide character equivalents are
printable.
.RE
.RS +4
.TP
.ie t \(bu
.el o
Typing other non-printable characters will cause them to be written to the
recipient's terminal as follows: control characters will appear as a `\fB^\fR'
followed by the appropriate \fBASCII\fR character, and characters with the
high-order bit set will appear in "meta" notation. For example, `\fB\e003\fR\&'
is displayed as `\fB^C\fR' and `\fB\e372\fR\&' as `\fBM\(miz\fR'.
.RE
.sp
.LP
To write to a user who is logged in more than once, the \fIterminal\fR argument
can be used to indicate which terminal to write to. Otherwise, the recipient's
terminal is the first writable instance of the user found in
\fB/usr/adm/utmpx\fR, and the following informational message will be written
to the sender's standard output, indicating which terminal was chosen:
.sp
.in +2
.nf
\fIuser\fR is logged on more than one place.
You are connected to \fIterminal\fR.
Other locations are:\fIterminal\fR
.fi
.in -2
.sp

.sp
.LP
Permission to be a recipient of a \fBwrite\fR message can be denied or granted
by use of the \fBmesg\fR utility. However, a user's privilege may further
constrain the domain of accessibility of other users' terminals. The
\fBwrite\fR utility will fail when the user lacks the appropriate privileges to
perform the requested action.
.sp
.LP
If the character \fB!\fR is found at the beginning of a line, \fBwrite\fR calls
the shell to execute the rest of the line as a command.
.sp
.LP
\fBwrite\fR runs \fBsetgid()\fR (see \fBsetuid\fR(2)) to the group \fBID\fR
\fBtty\fR, in order to have write permissions on other users' terminals.
.sp
.LP
The following protocol is suggested for using \fBwrite\fR: when you first
\fBwrite\fR to another user, wait for them to \fBwrite\fR back before starting
to send. Each person should end a message with a distinctive signal (that is,
\fB(o)\fR for \fIover\fR) so that the other person knows when to reply. The
signal \fB(oo)\fR (for \fBover and out\fR) is suggested when conversation is to
be terminated.
.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIuser\fR\fR
.ad
.RS 12n
User (login) name of the person to whom the message will be written. This
operand must be of the form returned by the \fBwho\fR(1) utility.
.RE

.sp
.ne 2
.na
\fB\fIterminal\fR\fR
.ad
.RS 12n
Terminal identification in the same format provided by the \fBwho\fR utility.
.RE

.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBwrite\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
The addressed user is not logged on or the addressed user denies permission.
.RE

.SH FILES
.sp
.ne 2
.na
\fB\fB/var/adm/utmpx\fR\fR
.ad
.RS 18n
User and accounting information for \fBwrite\fR
.RE

.sp
.ne 2
.na
\fB\fB/usr/bin/sh\fR\fR
.ad
.RS 18n
Bourne shell executable file
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Committed
_
Standard	See \fBstandards\fR(7).
.TE

.SH SEE ALSO
.sp
.LP
.BR mail (1),
.BR mesg (1),
.BR pr (1),
.BR sh (1),
.BR talk (1),
.BR who (1),
.BR setuid (2),
.BR termios (3C),
.BR attributes (7),
.BR environ (7),
.BR standards (7)
.SH DIAGNOSTICS
.sp
.ne 2
.na
\fB\fBuser is not logged on\fR\fR
.ad
.sp .6
.RS 4n
The person you are trying to \fBwrite\fR to is not logged on.
.RE

.sp
.ne 2
.na
\fB\fBPermission denied\fR\fR
.ad
.sp .6
.RS 4n
The person you are trying to \fBwrite\fR to denies that permission (with
\fBmesg\fR).
.RE

.sp
.ne 2
.na
\fB\fBWarning: cannot respond, set mesg\fR\fB-y\fR\fR
.ad
.sp .6
.RS 4n
Your terminal is set to \fBmesg\fR \fBn\fR and the recipient cannot respond to
you.
.RE

.sp
.ne 2
.na
\fB\fBCan no longer write to user\fR\fR
.ad
.sp .6
.RS 4n
The recipient has denied permission (\fBmesg n\fR) after you had started
writing.
.RE

